package inverse;

public class Main {

	public static void main(String[] args) {
		long b = 6;
		long p = (long) (1e9+7);
		//计算b模p的逆元
		exgcd(b,p);
		//输出b模p的逆元
		System.out.println(x);

	}
	
	//计算a模p的逆元
	static long x,y;
	static void exgcd(long a,long p){
		if(p==0){
			x=1;
			y=0;
			return;
		}
		exgcd(p,a%p);
		long k=x;
		x=y;
		y=k-a/p*y;
	}
	//最终所求逆元存储在x里

}
